@extends('layouts.admin')
@push('morecss')
@endpush

@push('morescript')
    <script type="application/javascript">
        let page_params = {
            @can('admin.wxtemplatemsg.index')
            url_list: '{{ route('admin.wxtemplatemsg.index') }}',
            @endcan
            @can('admin.wxtemplatemsg.setIndustry')
            url_setindustry: '{{ route('admin.wxtemplatemsg.setIndustry') }}',
            @endcan
            @can('admin.wxtemplatemsg.create')
            url_add: '{{ route('admin.wxtemplatemsg.create') }}',
            @endcan
            @can('admin.wxtemplatemsg.update')
            url_edit: '{{ route('admin.wxtemplatemsg.update') }}',
            @endcan
            @can('admin.wxtemplatemsg.destroy')
            url_del: '{{ route('admin.wxtemplatemsg.destroy') }}',
            @endcan
            @can('admin.wxtemplatemsg.sync')
            url_sync: '{{ route('admin.wxtemplatemsg.sync') }}',
            @endcan
            data_industry_list : @json($industryList),
            data_industry_set : @json($industrySet),
            data_key_list:@json($keyList),
        }
    </script>
    <!-- require page js -->
    <script src="{{ mix('js/admin/wxtemplatemsg_index.js') }}"></script>
@endpush
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight ecommerce">
        <div class="ibox-content m-b-sm border-bottom">
            <div class="row">
                <div class="col-sm-12">
                    模板消息仅用于公众号向用户发送重要的服务通知，只能用于符合其要求的服务场景中，如信用卡刷卡通知，商品购买成功通知等。不支持广告等营销类消息以及其它所有可能对用户造成骚扰的消息。
                </div>
                <div class="col-sm-12">
                    1、所有服务号都可以在功能->添加功能插件处看到申请模板消息功能的入口，但只有认证后的服务号才可以申请模板消息的使用权限并获得该权限；<br>
                    2、需要选择公众账号服务所处的2个行业，每月可更改1次所选行业；<br>
                    3、在所选择行业的模板库中选用已有的模板进行调用；<br>
                    4、每个账号可以同时使用25个模板。<br>
                    5、当前每个账号的模板消息的日调用上限为10万次，单个模板没有特殊限制。【2014年11月18日将接口调用频率从默认的日1万次提升为日10万次，可在MP登录后的开发者中心查看】。当账号粉丝数超过10W/100W/1000W时，模板消息的日调用上限会相应提升，以公众号MP后台开发者中心页面中标明的数字为准。<br>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="control-label" for="keyword">关键字</label>
                        <input type="text" id="keyword" name="keyword" value="" placeholder="请输入搜索关键字"
                               class="form-control">
                    </div>
                </div>
                <div class="col-sm-2">
                    <div class="form-group">
                        <label class="control-label" for="product_name">&nbsp;&nbsp;</label>
                        <div>
                            <button class="btn btn-primary" type="button" v-on:click="query"><i class="fa fa-search"></i>
                                搜索
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="toolbar" class="col-sm-2" style="width: 800px;">
            @can('admin.wxtemplatemsg.create')
                <button class="btn btn-primary" v-on:click="add"><i class="fa fa-plus"></i> 添加</button>
            @endcan
            @can('admin.wxtemplatemsg.sync')
                <button class="btn btn-primary" type="button" v-on:click="sync"><i class="fa fa-cloud-download"></i>
                    同步微信端
                </button>
            @endcan
            @can('admin.wxtemplatemsg.setIndustry')
                <button class="btn btn-primary" id="btn-setIndustry"><i class="fa fa-plus"></i> 设置行业</button>
                <label class="label label-info">
                    @if(!empty($industrySet['primary_industry_second_class']))主营行业:{{ $industrySet['primary_industry_first_class'] }} {{ $industrySet['primary_industry_second_class'] }}@endif
                    @if(!empty($industrySet['secondary_industry_second_class'])),副营行业:{{ $industrySet['secondary_industry_first_class'] }} {{ $industrySet['secondary_industry_second_class'] }}@endif
                </label>
            @endcan
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <table id="table" data-classes="table table-no-bordered">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="box-setIndustry" style="display: none;">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="POST" class="form-horizontal">
                        <div class="form-group">
                            <label class="col-sm-8 control-label">修改行业后，你在原有行业中的模版将被删除</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">主营行业：</label>
                            <div class="input-group col-sm-9">
                                <div class="col-sm-6">
                                    <select id="primary_industry_first_class" name="primary_industry_first_class" class="form-control">
                                    </select>
                                </div>
                                <div class="col-sm-6">
                                    <select id="primary_industry_second_class" name="primary_industry_second_class" class="form-control">
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">副营行业：</label>
                            <div class="input-group col-sm-9">
                                <div class="col-sm-6">
                                    <select id="secondary_industry_first_class" name="secondary_industry_first_class" class="form-control">
                                    </select>
                                </div>
                                <div class="col-sm-6">
                                    <select id="secondary_industry_second_class" name="secondary_industry_second_class" class="form-control">
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-4">
                                <button class="btn btn-primary btn-sub" type="button">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div id="box-form" style="display: none;">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="POST" class="form-horizontal">
                        <div class="form-group" v-show="!templateData.id">
                            <label class="col-sm-2 control-label">@{{ templateData.id }}模板编号</label>
                            <div class="col-sm-10">
                                <input type="text" name="template_id_short" id="template_id_short" v-model="templateData.template_id_short" class="form-control">
                                <span class="help-block m-b-none">模板库中模板的编号，有“TM**”和“OPENTMTM**”等形式</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">模板标识</label>
                            <div class="col-sm-10">
                                <select id="template_key" name="template_key" class="form-control" style="width: 200px;" v-model="templateData.template_key">
                                    <option value="">请选择</option>
                                    <option v-for="item in key_list" v-bind:value="item.type">@{{ item.name }}</option>
                                </select>
                                <span class="help-block m-b-none">该模板的唯一标识，与业务相关联，该数据由开发人员维护</span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-4">
                                <button class="btn btn-primary btn-sub" v-on:click="save" type="button">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection